home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / src / tooldebug / vudebug.c < prev   
C/C++ Source or Header  |  1997-05-08  |  8KB  |  319 lines

  1. #ifndef lint
  2. static char SccsId[]= "@(#)VUdebug.c    V1.10    3/13/95";
  3. #endif
  4. /*
  5. |    file name -  VUdebug.c
  6. |=======================================================================
  7. |
  8. |        copyright (C) 1987, V.I. Corporation
  9. |
  10. |    VUdebug -- Print datas tructure utilities for VP/VG layer
  11. |
  12. |    alan c morse    28 may 87    extracted from VU*print routines
  13. |
  14. |=======================================================================
  15. |
  16. |    Function Name    Description
  17. |    -------------    ------------------------------------------
  18. |    VUdbgCcf        Print the current state of the context flags
  19. |    VUdbgColor        Print contents of COLOR_SPEC structure
  20. |    VUdbgCtt        Print the color threshold table
  21. |    VUdbgDgp        Print the contents of datagroup
  22. |    VUdbgVdp        Print the contents of variable descriptor
  23. |
  24. |=======================================================================
  25. */
  26. #include "std.h"
  27. #include "dvstd.h"
  28. #include "VUfundecl.h"
  29. #include "VGfundecl.h"
  30.  
  31. BOOLPARAM VIdgvalid V_P_((ADDRESS dgp, char *fcn_name));
  32. BOOLPARAM VIvdvalid V_P_((ADDRESS vdp, char *fcn_name));
  33. char *MGdfname V_P_((ADDRESS fmtraddr));
  34.  
  35. /*======================================================================
  36. |
  37. |    VUdbgCcf
  38. |    Prints out context control flag data structure.
  39. */
  40. void 
  41. VUdbgCcf (dgp)
  42.      ADDRESS dgp;
  43. {
  44.   CHAR *label;
  45.   CHAR *yesp = "YES";
  46.   CHAR *nop = "NO";
  47.   LONG flags;
  48.  
  49.   if (!VIdgvalid (dgp, "VUdbgCcf"))
  50.     return;
  51.  
  52.   flags = VGdgcontext (dgp, V_F_ALL);
  53.   if (flags & V_FPRE_ERASE)
  54.     label = yesp;
  55.   else
  56.     label = nop;
  57.   (VOID) S_PRINTF ("pre erase: %s\t", label);
  58.   if (flags & V_FCONTEXT)
  59.     label = yesp;
  60.   else
  61.     label = nop;
  62.   (VOID) S_PRINTF ("context: %s\t", label);
  63.   if (flags & V_FLEGEND)
  64.     label = yesp;
  65.   else
  66.     label = nop;
  67.   (VOID) S_PRINTF ("legend: %s\t", label);
  68.   if (flags & V_FVPBOX)
  69.     label = yesp;
  70.   else
  71.     label = nop;
  72.   (VOID) S_PRINTF ("vp box: %s\n", label);
  73.  
  74.   (VOID) S_PRINTF ("Axes with ticks: ");
  75.   if (flags & V_FT_TICS)
  76.     {
  77.       (VOID) S_PRINTF ("time ");
  78.       if (flags & V_FT_LABEL_TICS)
  79.         (VOID) S_PRINTF ("labeled ");
  80.       if (flags & V_FT_GRID)
  81.         (VOID) S_PRINTF ("gridded ");
  82.       (VOID) S_PUTCHAR ('\t');
  83.     }
  84.  
  85.   if (flags & V_FD1_TICS)
  86.     {
  87.       (VOID) S_PRINTF ("d1 ");
  88.       if (flags & V_FD1_LABEL_TICS)
  89.         (VOID) S_PRINTF ("labeled");
  90.       (VOID) S_PUTCHAR ('\t');
  91.     }
  92.  
  93.   if (flags & V_FD2_TICS)
  94.     {
  95.       (VOID) S_PRINTF ("d2 ");
  96.       if (flags & V_FD2_LABEL_TICS)
  97.         (VOID) S_PRINTF ("labeled");
  98.       (VOID) S_PUTCHAR ('\t');
  99.     }
  100.  
  101.   if (flags & V_FV_TICS)
  102.     {
  103.       (VOID) S_PRINTF ("value ");
  104.       if (flags & V_FV_LABEL_TICS)
  105.         (VOID) S_PRINTF ("labeled");
  106.       if (flags & V_FV_GRID)
  107.         (VOID) S_PRINTF ("gridded ");
  108.     }
  109.   (VOID) S_PUTCHAR ('\n');
  110. }
  111.  
  112. /*======================================================================
  113. |
  114. |    VUdbgColor
  115. |    Prints contents of COLOR_SPEC data structure.
  116. */
  117. void 
  118. VUdbgColor (color)
  119.      COLOR_SPEC *color;
  120. {
  121.   if (color->rgb_rep.rgb_rep_flag)
  122.     (VOID) S_PRINTF ("R:%d G:%d B:%d ",
  123.                      (INT) color->rgb_rep.red,
  124.                      (INT) color->rgb_rep.green,
  125.                      (INT) color->rgb_rep.blue);
  126.   else
  127.     (VOID) S_PRINTF ("Index:%d ", (INT) color->color_index);
  128. }
  129.  
  130. /*======================================================================
  131. |
  132. |    VUdbgCtt
  133. |    Prints color threshold table contents.
  134. */
  135. void 
  136. VUdbgCtt (size, ct)
  137.      int size;
  138.      COLOR_THRESHOLD *ct;
  139. {
  140.   FAST INT i;
  141.  
  142.   (VOID) S_PRINTF ("%d\t", size);
  143.   if (size)
  144.     for (i = 0; i < size; i++)
  145.       {
  146.         if (size > 1)
  147.           (VOID) S_PRINTF ("Threshold: %d   ", (INT) ct[i].upperlimit);
  148.         (VOID) S_PRINTF ("Color ");
  149.         VUdbgColor ((COLOR_SPEC *) & ct[i].threshcolor.color_index);
  150.         (VOID) S_PUTCHAR ('\n');
  151.       }
  152.   else
  153.     VUdbgColor ((COLOR_SPEC *) ct);
  154. }
  155.  
  156. /*======================================================================
  157. |
  158. |    VUdbgVdp
  159. |    Prints out contents of a Variable Descriptor
  160. */
  161. void 
  162. VUdbgVdp (vdp)
  163.      ADDRESS vdp;
  164. {
  165.   INT arg1, arg2, arg3, vartype, accmode;
  166.   LONG irange1, irange2;
  167.   DOUBLE drange1, drange2;
  168.   CHAR *string, *vtype = "??";
  169.   COLOR_THRESHOLD *colorp;
  170.   DV_BOOL UseIrange;
  171.  
  172.   if (!VIvdvalid (vdp, (CHAR *) NULL))
  173.     {
  174.       (VOID) S_PRINTF ("Not a variable descriptor.\n");
  175.       return;
  176.     }
  177.  
  178.   (VOID) S_PRINTF ("variable descriptor: %lx", (LONG) vdp);
  179.   string = VGvdvarname (vdp);
  180.   if (string)
  181.     (VOID) S_PRINTF ("  name: %s", string);
  182.  
  183.   vartype = VGvdtype (vdp);
  184.   switch (vartype)
  185.     {
  186.     case V_C_TYPE:
  187.       UseIrange = YES;
  188.       vtype = "char";
  189.       break;
  190.     case V_UC_TYPE:
  191.       UseIrange = YES;
  192.       vtype = "unsigned char";
  193.       break;
  194.     case V_S_TYPE:
  195.       UseIrange = YES;
  196.       vtype = "short";
  197.       break;
  198.     case V_US_TYPE:
  199.       UseIrange = YES;
  200.       vtype = "unsigned short";
  201.       break;
  202.     case V_L_TYPE:
  203.       UseIrange = YES;
  204.       vtype = "long";
  205.       break;
  206.     case V_UL_TYPE:
  207.       UseIrange = YES;
  208.       vtype = "ULONG";
  209.       break;
  210.     case V_F_TYPE:
  211.       UseIrange = NO;
  212.       vtype = "float";
  213.       break;
  214.     case V_D_TYPE:
  215.       UseIrange = NO;
  216.       vtype = "double";
  217.       break;
  218.     case V_T_TYPE:
  219.       UseIrange = NO;
  220.       vtype = "text";
  221.       break;
  222.     default:
  223.       UseIrange = NO;
  224.       vtype = "??";
  225.       break;
  226.     }
  227.  
  228.   (VOID) S_PRINTF ("\ttype: %s ", vtype);
  229.   (VOID) S_PRINTF ("at %lx\n    ", (LONG) VGvdbase (vdp));
  230.  
  231.   if (UseIrange)
  232.     {
  233.       VGvd_irange (vdp, &irange1, &irange2);
  234.       (VOID) S_PRINTF ("range: %d to %d   ", (int)irange1, (int)irange2);
  235.     }
  236.   else if (vartype == V_F_TYPE || vartype == V_D_TYPE)
  237.     {
  238.       VGvd_drange (vdp, &drange1, &drange2);
  239.       (VOID) S_PRINTF ("range: %.7g to %.7g   ", drange1, drange2);
  240.     }
  241.  
  242.   VGvddim (vdp, &arg1, &arg2, &arg3);
  243.   (VOID) S_PRINTF ("size: %dx%dx%d", arg1, arg2, arg3);
  244.  
  245.   accmode = VGvd_accmode (vdp);
  246.   if (accmode == V_DIR_ACCESS)
  247.     (VOID) S_PRINTF ("\tdirect access  ");
  248.   else if (accmode == V_INDIR_ACCESS)
  249.     (VOID) S_PRINTF ("\tindirect access  ");
  250.   else if (accmode == V_DS_BOUND)
  251.     (VOID) S_PRINTF ("\tdata source bound ");
  252.   else
  253.     (VOID) S_PRINTF ("\tunknown access mode ");
  254.  
  255.   VGvdctt (vdp, &arg1, &colorp);
  256.   (VOID) S_PRINTF ("\n    ");
  257.   VUdbgCtt (arg1, colorp);
  258.  
  259.   string = VGvdvallabel (vdp);
  260.   if (string)
  261.     (VOID) S_PRINTF ("value label: %s\n", string);
  262. }
  263.  
  264. /*======================================================================
  265. |
  266. |    VUdbgDgp
  267. |    Prints out contents of DataGroup
  268. */
  269. void 
  270. VUdbgDgp (dgp)
  271.      ADDRESS dgp;
  272. {
  273.   FLOAT f1, f2, f3, f4;
  274.   CHAR *string;
  275.   RECTANGLE vp;
  276.  
  277.   if (!VIdgvalid (dgp, "VUdbgDgp"))
  278.     {
  279.       (VOID) S_PRINTF ("Not a datagroup\n");
  280.       return;
  281.     }
  282.  
  283.   (VOID) S_PRINTF ("\ndgp: %px ", dgp);
  284.  
  285.   string = VGdgtitle (dgp);
  286.   if (string)
  287.     (VOID) S_PRINTF ("\n%px, Title: %s ", dgp, string);
  288.   (VOID) S_PRINTF ("%d variables\n", (INT) VGvdget (dgp, 0));
  289.  
  290.   VGdgvp (dgp, &vp);
  291.   f1 = (float) vp.ll.x / 32767;
  292.   f2 = (float) vp.ll.y / 32767;
  293.   f3 = (float) vp.ur.x / 32767;
  294.   f4 = (float) vp.ur.y / 32767;
  295.   (VOID) S_PRINTF ("viewport: (%.2f,%.2f) (%.2f,%.2f)\n", f1, f2, f3, f4);
  296.   (VOID) S_PRINTF ("device:  %d    ", VGdgdevice (dgp));
  297.   (VOID) S_PRINTF ("%d slots    ", VGdgslots (dgp));
  298.  
  299.   /* Print the name of the graph */
  300.   string = MGdfname (VGdgdf (dgp));
  301.   if (string)
  302.     (VOID) S_PRINTF ("graph:  %s", string);
  303.   (VOID) S_PUTCHAR ('\n');
  304.  
  305.   VUdbgCcf (dgp);
  306.  
  307.   string = VGdgaxlabel (dgp, 't');
  308.   if (string)
  309.     (VOID) S_PRINTF ("time label: %s\n", string);
  310.   string = VGdgaxlabel (dgp, '1');
  311.   if (string)
  312.     (VOID) S_PRINTF ("d1 label:   %s\n", string);
  313.   string = VGdgaxlabel (dgp, '2');
  314.   if (string)
  315.     (VOID) S_PRINTF ("d2 label:   %s\n", string);
  316.  
  317.   VUvdtraverse (VGvdget (dgp, 1), VUdbgVdp);
  318. }
  319.